package models

type order_details struct {
	order_details_id string `gorm:"colunmn:order_details_id"`
	Order_id string `gorm:"column:order_id"`
	Goods_id string `gorm:"column:goods_id"`
	Ordgoods_number int64 `gorm:"column:ordgoods_number"`
	Factory_id string `gorm:"column:factory_id"`
	Order_sum_money int64 `gorm:"column:order_sum_money"`
}

func GetAlldetails() (error, []order_details, int64)  {
	var order_detailsdata []order_details
	//page := goodsParam["page"].(int)
	//pageSize := goodsParam["limit"].(int)
	//searchText := goodsParam["searchText"].(string)
	var total int64
	err := db.Table("order_details").Order("order_details_id ASC").Count(&total).Find(&order_detailsdata).Error

	return err, order_detailsdata, total
}

func Addorder_details() (error, order_details) {

	//a.BindJSON(&injurydata)
	//injurydata.Is_del = false
	//injurydata.Update_username = "系统管理员"
	//injurydata.Update_time = time.Now()
	order_detailsdata := order_details{"4","4","5",10,"03",300}
	err := db.Table("order_details").Create(&order_detailsdata).Error
	return err, order_detailsdata
}

func Updateorder_details() (error, order_details) {

	//a.BindJSON(&injurydata)
	//injurydata.Update_username = "系统管理员"
	//injurydata.Update_time = time.Now()
	order_detailsdata := order_details{"4","4","5",10,"03",300}
	err := db.Table("order_details").Where("order_details_id = ?", order_detailsdata.order_details_id).Updates(&order_detailsdata).Error
	return err, order_detailsdata
}

func Delorder_details() error {
	id := "1"
	err := db.Table("order_details").Where("order_details_id = ?", id).Delete(order_details{}).Error
	return err
}

